Skip to content

PHOENIX-7786 Improved handling for empty files in Replication Log Processor#2392

Open
Himanshu-g81 wants to merge 6 commits intoapache:PHOENIX-7562-feature-newfrom
Himanshu-g81:PHOENIX-7786
Open

PHOENIX-7786 Improved handling for empty files in Replication Log Processor#2392
Himanshu-g81 wants to merge 6 commits intoapache:PHOENIX-7562-feature-newfrom
Himanshu-g81:PHOENIX-7786

Conversation

@Himanshu-g81
Copy link
Contributor

No description provided.

// If trailer is missing or corrupt, create reader without trailer validation
LOG.warn("Invalid Trailer for file {}", filePath, invalidLogTrailerException);
logFileReaderContext.setValidateTrailer(false);
logFileReader.init(logFileReaderContext);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 2 init calls here so we need to handle failures from any of the two and close the reader

@Himanshu-g81 Himanshu-g81 requested a review from tkhurana March 21, 2026 04:01
// If trailer is missing or corrupt, create reader without trailer validation
LOG.warn("Invalid Trailer for file {}", filePath, invalidLogTrailerException);
// close the reader first to avoid leaking socket connection
logFileReader.close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this still doesn't completely fix the issue. While it fixes the leak, you simply cannot use the same LogFileReader object because it internally maintains a closed state and then when you try to iterate it will not return any result. https://github.com/apache/phoenix/blob/PHOENIX-7562-feature-new/phoenix-core-server/src/main/java/org/apache/phoenix/replication/log/LogFileReader.java#L73-L74
You have to construct a new LogFileReader object. This also means you need to enhance your test to correctly capture the issue.

closeReader(logFileReader);
logFileReaderContext.setValidateTrailer(false);
LogFileReader newLogFileReader = new LogFileReader();
newLogFileReader.init(logFileReaderContext);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we are leaking the reference newLogFileReader. Maybe don't introduce a new reference and reassign the existing reference logFileReader to the new object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants